package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleCommonDto;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.comment.dtos.ALLCommentListDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author JianKang
 * @create 2023-10-21 17:23
 */

@RestController
public class ArticleClient implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;


    @PostMapping("/api/v1/article/save")
    @Override
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        return apArticleService.saveArticle(dto);
    }

    @Override
    @GetMapping("/api/v1/article/update_views/{id}")
    public ResponseResult updateViews(@PathVariable Long id) {
        return apArticleService.updateViews(id);
    }

    @GetMapping("/api/v1/article/update_likes/{id}")
    @Override
    public ResponseResult updateLikes(@PathVariable Long id) {
        return apArticleService.updateLikes(id);
    }

    @PostMapping("/api/v1/article/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody ALLCommentListDto dto) {
        return apArticleService.findNewsComments(dto);
    }

    @Override
    @PostMapping("/api/v1/article/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody ArticleCommonDto dto) {
        return apArticleService.updateCommentStatus(dto);
    }
}
